package com.yyk.springserviceone.controller;

import com.alibaba.druid.stat.DruidStatManagerFacade;
import com.yyk.config.commonService.response.YYKCloudResponse;
import com.yyk.springserviceone.entity.AnchorLiveRoom;
import com.yyk.springserviceone.mapper.OneMapper;
import com.yyk.springserviceone.service.OneService;
import com.yyk.springservicetwo.facade.TwoFacade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author ljp
 * @CLASSNAME OneController
 * @date 2020/12/3 16:43
 * @description：
 */

@RestController
@RequestMapping("one")
public class OneController {

    @Resource
    private TwoFacade twoFacade;

    @Autowired
    private OneService oneService;
    @Autowired
    private OneMapper oneMapper;

    @GetMapping("get")
    public YYKCloudResponse<String> getOneService() {
        twoFacade.getTwoInfo("222");
        return YYKCloudResponse.success("GET请求成功--one");
    }

    @PostMapping("post")
    public YYKCloudResponse<String> postOneService() {
        return YYKCloudResponse.success("POST请求成功--one");
    }


    @GetMapping("getOne/{id}")
    public YYKCloudResponse<AnchorLiveRoom> getOne(@PathVariable("id")Long id) {

        return YYKCloudResponse.success(oneService.getById(id));
    }
    @GetMapping("/druid/stat")
    public YYKCloudResponse<Object> druidStat(){
        // DruidStatManagerFacade#getDataSourceStatDataList 该方法可以获取所有数据源的监控数据，除此之外 DruidStatManagerFacade 还提供了一些其他方法，你可以按需选择使用。
        return YYKCloudResponse.success(DruidStatManagerFacade.getInstance().getDataSourceStatDataList());
    }
}
